<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.autocomplete.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.autocomplete.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/md5.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.form.js"></script>
<script type="text/javascript">
/*required*/
var is_leaf = "<?=Q::ini('custom_flag/online_ebay_listing_categories_leaf/leaf/value')?>";
var is_free = "<?=Q::ini('custom_flag/online_ebay_listing_shipping_free/free/value')?>";
var browse_categories_ajax_url = "<?=url('Online::EbayListing/BrowseCategoriesAjax')?>";
var get_info_by_shop_and_site_ajax_url = "<?=url('Online::EbayListing/GetInfoByShopAndSiteAjax') ?>";
var get_info_by_site_ajax_url = "<?=url('Online::EbayListing/GetInfoBySiteAjax')?>";
var get_info_by_categories_ajax_url = "<?=url('Online::EbayListing/GetInfoByCategoryAjax')?>";
var search_category_ajax_url = "<?=url('Online::EbayListing/SearchCategoryAjax')?>";
var submit_url = "<?=url('Online::EbayListing/CreateSave')?>";
var verify_url = "<?=url('Online::EbayListing/VerifyAjax')?>";
var SUCCESS = "<?=SUCCESS?>";

/*custom*/
var currency_symbol;
var currency_code;
var custom_item_specifics_no = 0;
var variaiont_index = 1;
var shipping_location;
var domestic_shipping_service_option_html;
var domestic_shipping_index = 1;
var international_shipping_service_option_html;
var international_shipping_index = 1;
</script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/online.ebay.js?20150310"></script>

<form action="<?=url('Online::EbayListing/CreateSave')?>" method="post" id="submit_form">
<a href="<?=url('Online::EbayListing/FolderList')?>" class="folder">Manage Folders</a>
<table class="form_table">
<tr>
	<th>Folder</th>
	<td>
		<select name="folder_id" id="folder">		
			<option value="">请选择</option>
			<?foreach ($folder as $f):?>
			<option value="<?=$f['id']?>"><?=$f['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
</table>

<hr />

<table class="form_table">
<tr>
	<th>Shop</th>
	<td>
		<select name="shop_id" id="shop">		
			<option value="">请选择</option>
			<?foreach ($shop as $s):?>
			<option value="<?=$s['id']?>"><?=$s['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>Market</th>
	<td>
		<select name="site" id="site">
			<option value="">请选择</option>
			<?foreach (Q::ini('custom_flag/online_ebay_listing_site') as $s):?>
			<option value="<?=$s['value']?>"><?=$s['name']?> - <?=$s['value']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
</table>

<hr />

<table class="form_table">
<tr>
	<th>Primary Category</th>
	<td>
		<input type="text" name="primary_category" value="" size="7" readonly="readonly" id="primary_category" />
		<a href="#select_ebay_category_box" class="browse-ebay-category-btn" id="browse_ebay_primary_category_btn"><input type="button" value="Browse" class="button" /></a>
		<span></span><input type="hidden" name="primary_category_name" />
	</td>
</tr>
<tr>
	<th>Second Category</th>
	<td>
		<input type="text" name="second_category" value="" size="7" readonly="readonly" class="input-mini" />
		<a href="#select_ebay_category_box" class="browse-ebay-category-btn" id="browse_ebay_second_category_btn"><input type="button" value="Browse" class="button" /></a>
		<span></span><input type="hidden" name="second_category_name" />
	</td>
</tr>
<tr>
	<th><span class="store-category-loading"></span>Store Category</th>
	<td>
		<select name="store_category" class="store-category-select">
			<option value="">--none--</option>
		</select>
	</td>
</tr>
<tr>
	<th><span class="store-category-loading"></span>Store Category 2</th>
	<td>
		<select name="store_category2" class="store-category-select">
			<option value="">--none--</option>
		</select>
	</td>
</tr>
<tr>
	<th>Title</th>
	<td><input type="text" name="title" id="title" size="100" /><span style="color: red;"></span></td>
</tr>
<tr>
	<th><span class="condition-loading"></span>Condition</th>
	<td>
		<input type="hidden" name="condition_name" />
		<select name="condition_id" id="condition_id">
			<option value="">--none--</option>
		</select>
	</td>
</tr>
<tr>
	<th>Condition Description</th>
	<td><textarea style="width: 600px;" name="condition_description" id="condition_description" readonly="readonly"></textarea></td>
</tr>
</table>

<hr />
<table class="form_table">
<tbody>
	<tr>
		<th width="120">Custom Label / SKU</th>
		<td><input type="text" name="listing_sku" /></td>
	</tr>
	<tr>
		<th><span class="listing-type-loading"></span>Listing Type</th>
		<td>
			<label><input type="radio" name="listing_type" value="Chinese" checked="checked" id="Chinese_radio" />Standard Auction</label>
			<label><input type="radio" name="listing_type" value="FixedPriceItem" id="FixedPriceItem_radio" />Standard Fixed Price</label>
			<label id="MultiSKU_label"><input type="radio" name="listing_type" value="MultiSKU" id="MultiSKU_radio" />Multi SKU Variations Fixed Price</label>
		</td>
	</tr>
</tbody>
<tbody id="Chinese_tbody" class="listing-type-body">
	<tr>
		<th>Quantity</th>
		<td><input type="text" name="Chinese_quantity" value="1" size="6" readonly="readonly" /></td>
	</tr>
	<tr>
		<th><span class="price-loading"></span>Starting Price</th>
		<td>
			<span class="currency_symbol"></span>
			<input type="text" name="Chinese_start_price" size="7">
			<span class="currency_code"></span>
		</td>
	</tr>
	<tr>
		<th><span class="price-loading"></span>Buy It Now Price</th>
		<td>
			<span class="currency_symbol"></span>
			<input type="text" name="Chinese_buy_it_now_price" size="7">
			<span class="currency_code"></span>
		</td>
	</tr>
	<tr>
		<th>Duration</th>
		<td>
			<?foreach (Q::ini('custom_flag/online_ebay_listing_duration/standard_auction') as $k => $d):?>
			<label><input type="radio" name="Chinese_duration" value="<?=$d?>" <?if ($k == 0):?>checked="checked"<?endif;?> /><?=$d?></label>
			<?endforeach;?>
		</td>
	</tr>
</tbody>
<tbody id="FixedPriceItem_tbody" class="listing-type-body" style="display: none;">
	<tr>
		<th>Quantity</th>
		<td><input type="text" name="FixedPriceItem_quantity" size="6" /></td>
	</tr>
	<tr>
		<th><span class="price-loading"></span>Fixed Price</th>
		<td>
			<span class="currency_symbol"></span>
			<input type="text" name="FixedPriceItem_start_price" size="7">
			<span class="currency_code"></span>
		</td>
	</tr>
	<tr>
		<th>Duration</th>
		<td>
			<?foreach (Q::ini('custom_flag/online_ebay_listing_duration/standard_fixed_price') as $k => $d):?>
			<label><input type="radio" name="FixedPriceItem_duration" value="<?=$d?>" <?php if ($k == 0):?>checked="checked"<?endif;?> /><?=$d?></label>
			<?endforeach;?>
		</td>
	</tr>
</tbody>
<tbody id="MultiSKU_tbody" class="listing-type-body" style="display: none;">
	<tr>
		<th>Duration</th>
		<td>
			<?foreach (Q::ini('custom_flag/online_ebay_listing_duration/multi_sku_variations_fixed_price') as $k => $d):?>
			<label><input type="radio" name="MultiSKU_duration" value="<?=$d?>" <?php if ($k == 0):?>checked="checked"<?endif;?> /><?=$d?></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th style="vertical-align: text-top;">Variations</th>
		<td>
			<div id="MultiSKU_variation_specifics"></div>
			<div id="MultiSKU_variation_specifics_content" style="display: none;"></div>
			<table class="list_table" id="MultiSKU_variation_content">
			<thead>
				<tr>
					<th><span class="MultiSKU-variation-specifics-text">Sub SKU</span></th>
					<th><span class="MultiSKU-variation-specifics-text">Quantity</span></th>
					<th><span class="MultiSKU-variation-specifics-text">Price</span></th>
					<th><a href="javascript:;" id="MultiSKU_variation_specifics_add_btn">Add Specific</a><input type="text" size="10" id="MultiSKU_variation_specifics_add_text" style="display: none;" /></th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td><input type="text" name="variation[add0][Sub SKU]" size="10" /></td>
					<td><input type="text" name="variation[add0][Quantity]" size="6" /></td>
					<td>
						<span class="currency_symbol"></span>
						<input type="text" name="variation[add0][Price]" size="7">
						<span class="currency_code"></span>
					</td>
					<td><input type="hidden" class="variation-index" value="add0" /></td>
				</tr>
			</tbody>
			</table>
			<a href="javascript:;" id="add_variation_btn">+ Add Variation</a>
		</td>
	</tr>
</tbody>
<tbody>
	<tr>
		<th style="vertical-align: text-top;"><span class="item-specifics-loading"></span>Item Specifics</th>
		<td>
			<div id="default_item_specifics"></div>
			<div id="default_item_specifics_content"></div>
			<div id="custom_item_specifics_content"></div>
			<a href="javascript:;" id="add_custom_item_specifics_btn">+ Add Custom Specifics</a>
		</td>
	</tr>
</tbody>
</table>

<hr />
<table class="form_table">
<tr>
	<th style="vertical-align: text-top;">Image</th>
	<td>
		<table class="list_table">
		<tbody>
			<tr>
				<th width="110">Pictures</th>
				<td align="left">
					<textarea name="picture_urls" style="width: 700px;height: 150px;white-space:nowrap;overflow:scroll;resize: none;" placeholder="Multiple URLs; one URL per Line"></textarea>
				</td>
			</tr>
		</tbody>
		<tbody id="MultiSKU_variation_pictures_tbody" style="display: none;">
			<tr>
				<th>Variation Pictures</th>
				<td align="left"><select id="MultiSKU_variation_pictures_specifics_refresh_select" name="MultiSKU_variation_pictures_specifics"><option value="">--none--</option></select> <a href="javascript:;" id="MultiSKU_variation_pictures_specifics_refresh_btn">Refresh</a></td>
			</tr>
		</tbody>
		<tbody id="MultiSKU_variation_pictures_content" style="display: none;"></tbody>
		</table>
	</td>
</tr>
</table>

<hr />
<table class="form_table">
<tr>
	<th style="vertical-align: text-top;">Description<br /><a href="javascript:;" id="preview_btn">Preview</a></th>
	<td width="1000"><textarea name="description" id="description" style="width: 900px;" rows="20"></textarea></td>
</tr>
<tr>
	<th>Hit Counter</th>
	<td>
		<select name="counter">
		<?foreach (Q::ini('custom_flag/online_ebay_listing_counter') as $c):?>
		<option value="<?=$c?>"><?=$c?></option>
		<?endforeach;?>
		</select>
	</td>
</tr>
</table>

<hr />
<table class="form_table">
<tr>
	<th><span class="shipping-loading"></span>Dispatch Time</th>
	<td>
		<select name="dispatch_time" id="dispatch_time_select"><option value="">--none--</option></select>
		<label><input type="checkbox" name="get_it_fast" value="<?=Q::ini('custom_flag/online_ebay_listing_get_it_fast/fast/value')?>" />Get-It-Fast</label> 
	</td>
</tr>
<tr>
	<th style="vertical-align: text-top;">
		<span class="shipping-loading"></span>Domestic Shipping<br />
		<a id="add_domestic_shipping_service_btn" href="javascript:;">+ Add Shipping Services</a>
	</th>
	<td>
		<table class="list_table">
			<tbody id="domestic_shipping_service_content"></tbody>
		</table>
	</td>
</tr>
<tr>
	<th style="vertical-align: text-top;">
		<span class="shipping-loading"></span>International Shipping<br />
		<a id="add_international_shipping_service_btn" href="javascript:;">+ Add Shipping Services</a>
	</th>
	<td>
		<table class="list_table">
			<tbody id="international_shipping_service_content"></tbody>
		</table>
	</td>
</tr>
</table>

<hr />
<table class="form_table">
<tr>
	<th>AutoPay</th>
	<td><label><input type="checkbox" name="auto_pay" value="<?=Q::ini('custom_flag/online_ebay_listing_auto_pay/auto/value')?>" checked="checked" />AutoPay</label></td>
</tr>
<tr>
	<th>Item Location</th>
	<td>
		Country: <select name="country">
			<?foreach ($country as $c):?>
			<option value="<?=$c['code']?>" <?if ($c['code'] == Q::ini('custom_flag/online_ebay_listing_default_country')):?>selected="selected"<?endif;?>><?=$c['en_name']?></option>
			<?endforeach;?>
		</select>
		Zip/Postal code: <input type="text" name="postal_code" value="<?=Q::ini('custom_flag/online_ebay_listing_default_postal_code')?>" />
		Location: <input type="text" name="location" value="<?=Q::ini('custom_flag/online_ebay_listing_default_location')?>" />
	</td>
</tr>
<tr>
	<th><span class="return-policy"></span>Return Policy</th>
	<td>
		<table class="list_table">
			<tbody><tr><th width="200">Accepted</th><td align="left" id="return_policy_accepted_content"></td></tr></tbody>
			<tbody id="return_policy_content" style="display: none;"></tbody>
		</table>
	</td>
</tr>
</table>
<hr />
<table class="form_table">
<tr>
	<th><input type="checkbox" id="set_schedule" name="set_schedule" <?=isset($listing['schedule_date'])?'checked="checked"':""?>"/>Schedule Time</th>
	<td>
	<div id="schedule_div">
		<input name="date" id="date" value="" class="datepicker" /> /&nbsp;
		<select id="hour" name="hour">
				<?for ($i = 0; $i < 24; $i++):?>
				<option value="<?=str_pad($i, 2, 0, STR_PAD_LEFT)?>"><?=str_pad($i, 2, 0, STR_PAD_LEFT)?></option>
				<?endfor;?>
		</select> 时 :
		<select id="minute" name="minute">
				<?for ($j = 0; $j < 60; $j++):?>
				<option value="<?=str_pad($j, 2, 0, STR_PAD_LEFT)?>"><?=str_pad($j, 2, 0, STR_PAD_LEFT)?></option>
				<?endfor;?>
		</select> 分  =>
		<label>Timezone</label>
		<select id="timezone" name="timezone">
				<?foreach (Q::ini('custom_flag/timezone') as $z):?>
				<option value="<?=$z['value']?>" ><?=$z['name']?></option>
				<?endforeach;?>
		</select>
		<span id="show_time"></span>
	</div>
	</td>
</tr>
<tr>
	<th><input type="checkbox" id="schedule_repeat" name="schedule_repeat" <?=isset($listing['schedule_repeat']) ? 'checked="checked"' : ""?>"/>Repeat Duration</th>
	<td>
		<input id="schedule_repeat_step" name="schedule_repeat_step" value="<?=isset($listing['schedule_repeat_step']) ? $listing['schedule_repeat_step'] : ''?>" />Days
	</td>
</tr>
</table>
</form>
<div align="center" style="width: 70%; margin-top: 8px;">
<input type="button" value="提交" class="button" id="submit_btn" />
<input type="button" value="检测错误&费用" class="button" style="width: 100px;" id="verify_btn" />
<img src="<?=Q::ini('custom_system/base_url')?>img/loading.gif" style="display: none" />
</div>


<!-- ebay categories select box -->
<div id="select_ebay_category_box" style="display: none;">
<h1 style="background: #eee; font-size: 16px; padding: 10px 0px 10px 10px;">Select a Category...</h1>
<table width="100%" style="text-align: center;">
<tr>
	<td height="40px" colspan="3" align="left">
		搜索产品分类&nbsp;&nbsp;<input type="text" id="ebay_category_search_input" value="" size="100" />
	</td>
</tr>
<tr>
	<td colspan="3" align="left">选择产品分类</td>
</tr>
<tr>
	<td width="33%">
		<input type="hidden" value="" class="categories-select" id="categories_0">
		<span>Primary Category</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_1"></select>
	</td>
	<td width="33%">
		<span>Sub Category #1</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_2"></select>
	</td>
	<td width="33%">
		<span>Sub Category #2</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_3"></select>
	</td>
</tr>
<tr>
	<td width="33%">
		<span>Sub Category #3</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_4"></select>
	</td>
	<td width="33%">
		<span>Sub Category #4</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_5"></select>
	</td>
	<td width="33%">
		<span>Sub Category #5</span>
		<select size="8" style="width: 100%" class="categories-select" id="categories_6"></select>
	</td>
</tr>
</table>
<p><strong>Selected Category: </strong><span id="categories_select_id"></span></p>
<p><strong>Selected Category Name: </strong><span id="categories_select_name"></span></p>
<div align="right">
<input type="button" value="Cancel" class="button" id="select_ebay_category_cancel_btn" />
<input type="button" value="Select" class="button" id="select_ebay_category_select_btn" />
<input type="hidden" id="ebay_categories_callback_btn" value="" />
</div>
</div>

<div id="dialog_verify_info" title="上架检测错误信息和上架费用提示">
<table class="list_table" width="100%">
	<tr>
		<th width="60">结果</th>
		<td id="verify_ack" align="left"></td>
	</tr>
	<tr>
		<th>错误信息</th>
		<td id="verify_errors" align="left"></td>
	</tr>
	<tr>
		<th>上架费用</th>
		<td id="verify_fee" align="left"></td>
	</tr>
</table>
</div>
<?php $this->_endblock();?>